package com.maila.simplerecord.utils;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import java.io.Serializable;


/**
 * 界面跳转
 * Created by ld_srg on 2016/3/31.
 */
public class StartActivityUtils {


    public static boolean checklogin(Context mcontext){

        return true;
    }

    public static void start(Context mcontext, Class<?> cla) {
        if(checklogin(mcontext)) {


        }
    }

    public static void startToGoods(Context mcontext, Class<?> cla, String id) {
            Intent intent = new Intent(mcontext, cla);
            Bundle bundle = new Bundle();
            bundle.putString("goods_id", id);
            intent.putExtras(bundle);
            mcontext.startActivity(intent);
    }
    public static void startByOpt(Context mcontext, Class<?> cla,  int OPT, Object bundle ) {
        Intent intent = new Intent(mcontext, cla);
        intent.putExtra("OPT", OPT);
        intent.putExtra("data", (Serializable) bundle);
        mcontext.startActivity(intent);
    }
    public static void start(Context mcontext, Class<?> cla,  Object bundle ) {
        Intent intent = new Intent(mcontext, cla);
        intent.putExtra("data", (Serializable) bundle);
        mcontext.startActivity(intent);
    }
    public static void startToShop(Context mcontext, Class<?> cla, String id) {
        Intent intent = new Intent(mcontext, cla);
        Bundle bundle = new Bundle();
        bundle.putString("supplier_id", id);
        intent.putExtras(bundle);
        mcontext.startActivity(intent);
    }

    public static void startToSearch(Context mcontext, Class<?> cla, String keywords,String cat_id,String searchtype) {
        Intent intent=new Intent(mcontext, cla);
        Bundle bundle = new Bundle();
        bundle.putString("search",keywords );
        bundle.putString("searchtype", searchtype);
        bundle.putString("cat_id",cat_id);
        intent.putExtras(bundle);
        mcontext.startActivity(intent);
    }

    public static void startByOpt(Context mcontext, Class<?> cla, int OPT, String str) {
        if(checklogin(mcontext)){
            Intent it = new Intent();
            it.putExtra("OPT", OPT);
            it.putExtra("str", str);
            it.setClass(mcontext, cla);
            mcontext.startActivity(it);
        }

    }

    public static void startByOpt(Context mcontext, Class<?> cla, int ID, int OPT) {
        if(checklogin(mcontext)) {
            Intent it = new Intent();
            it.putExtra("opt", OPT);
            it.putExtra("pid", ID);
            it.setClass(mcontext, cla);
            mcontext.startActivity(it);
        }
    }

    public static void start(Context mcontext, Class<?> cla, int id, Bundle claa) {
        if(checklogin(mcontext)) {
            Intent it = new Intent();
            it.putExtra("ID", id);
            it.putExtras(claa);
            it.setClass(mcontext, cla);
            mcontext.startActivity(it);
        }
    }

    public static void start(Context mcontext, Class<?> cla, int id, Bundle claa, int position) {
        if(checklogin(mcontext)) {
            Intent it = new Intent();
            it.putExtra("ID", id);
            it.putExtra("position", position);
            it.putExtras(claa);
            it.setClass(mcontext, cla);
            mcontext.startActivity(it);
        }
    }

    public static void start(Context mcontext, Class<?> cla, String city) {
        if(checklogin(mcontext)) {
            Intent it = new Intent();
            it.putExtra("str", city);
            it.setClass(mcontext, cla);
            mcontext.startActivity(it);
        }
    }

    public static void start(Context mcontext, Class<?> cla, String city, int ID) {
        if(checklogin(mcontext)) {
            Intent it = new Intent();
            it.putExtra("str", city);
            it.putExtra("ID", ID);
            it.setClass(mcontext, cla);
            mcontext.startActivity(it);
        }
    }
}
